#include <stdio.h>
#include <atmi.h>
#include <fml32.h>
#include <Usysfl32.h>
#include <tpadm.h>

main(int argc, char *argv[])
{
	int	ret;

	if (tpinit((TPINIT *) NULL) == -1) {
		(void) printf("Tpinit failed[%s]\n", tpstrerror(tperrno));
		exit(1);
	}

	ret = tpchkconn();
	printf("ret:%d\n", ret);
	/* -----------------------------
	....
	check code
	...
	------------------------------*/
	tpterm();
}

int tpchkconn( void )
{
	FBFR32 	*sendbuf, *rcvbuf;
	long	len;
	
	if((sendbuf = (FBFR32 *)tpalloc("FML32", NULL, 1024)) == NULL) {
		printf("tpalloc error : %s\n", tpstrerror(tperrno));
		exit(1);
	}
	if((rcvbuf = (FBFR32 *)tpalloc("FML32", NULL, 1024)) == NULL) {
		printf("tpalloc error : %s\n", tpstrerror(tperrno));
		tpfree((char *)sendbuf);
		exit(1);
	}

	Finit32(sendbuf, Fsizeof32(sendbuf));
   	Finit32(rcvbuf, Fsizeof32(rcvbuf));
	Fchg32(sendbuf, TA_CLASS, 	0, "T_SERVER", 0);
 	Fchg32(sendbuf, TA_OPERATION, 	0, "GET", 0);
 	Fchg32(sendbuf, TA_SERVICENAME,	0, "WSL", 0);

	if(tpcall(".TMIB", (char *)sendbuf, 0, (char **)&rcvbuf, &len, TPNOTRAN|TPNOCHANGE|TPSIGRSTRT|TPNOTIME) == -1) {
		printf("tpcall failed: %s\n", tpstrerror(tperrno));
		return(tperrno);
	}

	tpfree((char *)sendbuf);
	tpfree((char *)rcvbuf);
	return(0);
}

